﻿<Tabs Class="layout-tabs" Type="@TabType.EditableCard" HideAdd @bind-ActiveKey="activeKey" OnClose="OnClose">
    @foreach (var item in Items)
    {
        <TabPane Key="@item.Id" Tab="@item.Name" Closable="@item.Closable">
            <DynamicComponent Type="item.ComType" Parameters="item.ComParameters" />
        </TabPane>
    }
</Tabs>

@code {
    private string activeKey;

    [Parameter] public List<Known.MenuItem> Items { get; set; }
    [Parameter] public Known.MenuItem Menu { get; set; }

    protected override async Task OnParametersSetAsync()
    {
        await base.OnParametersSetAsync();
        activeKey = Menu.Id;
    }

    private void OnClose(string tab)
    {
        var item = Items.FirstOrDefault(t => t.Id == tab);
        Items.Remove(item);
    }
}